package com.ruoyi.finance.withdrawOrder.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.finance.withdrawOrder.domain.SzWithdrawalRecord;
import com.ruoyi.finance.withdrawOrder.service.RYWithdrawalRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提现订单Controller
 *
 * @author wangmh
 * @date 2023-10-24
 */
@RestController
@RequestMapping("/finance/withdrawOrder")
public class SzWithdrawalRecordController extends BaseController {
    @Autowired
    private RYWithdrawalRecordService szWithdrawalRecordService;

    /**
     * 查询提现订单列表
     */
    @PreAuthorize("@ss.hasPermi('finance:withdrawOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzWithdrawalRecord szWithdrawalRecord) {
        startPage();
        List<SzWithdrawalRecord> list = szWithdrawalRecordService.selectSzWithdrawalRecordList(szWithdrawalRecord);
        return getDataTable(list);
    }

    /**
     * 导出提现订单列表
     */
    @PreAuthorize("@ss.hasPermi('finance:withdrawOrder:export')")
    @Log(title = "提现订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SzWithdrawalRecord szWithdrawalRecord) {
        List<SzWithdrawalRecord> list = szWithdrawalRecordService.selectSzWithdrawalRecordList(szWithdrawalRecord);
        ExcelUtil<SzWithdrawalRecord> util = new ExcelUtil<SzWithdrawalRecord>(SzWithdrawalRecord.class);
        return util.exportExcel(list, "提现订单数据");
    }

    /**
     * 获取提现订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('finance:withdrawOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(szWithdrawalRecordService.selectSzWithdrawalRecordById(id));
    }

    /**
     * 新增提现订单
     */
    @Log(title = "提现订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzWithdrawalRecord szWithdrawalRecord) {
        return toAjax(szWithdrawalRecordService.insertSzWithdrawalRecord(szWithdrawalRecord));
    }

    /**
     * 发放驳回
     */
    @PreAuthorize("@ss.hasPermi('finance:withdrawOrder:edit')")
    @Log(title = "体现订单-发放驳回", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzWithdrawalRecord szWithdrawalRecord) {
        return szWithdrawalRecordService.updateSzWithdrawalRecord(szWithdrawalRecord);
    }

    /**
     * 删除提现订单
     */
    @Log(title = "提现订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(szWithdrawalRecordService.deleteSzWithdrawalRecordByIds(ids));
    }
}
